<?php slot('js_insideLoadFunction')?>
ADMIN_FILTER.key_search = '<?php echo __('filter_key_search',null,'table_list')?>';
ADMIN_FILTER.enabled = '<?php echo (intval($data['filter']['filter_enabled'])>=0 && intval($data['filter']['filter_enabled'])<=1)?$data['filter']['filter_enabled']:'-1'?>';
ADMIN_FILTER.action = {
	error:{
		rowSelectedEmpty: '<?php echo __('error_row_selected', null, 'table_list')?>'
	},
	confirm:{
		deleteConfirm: '<?php echo __('row_delete_confirm', null, 'table_list')?>'
	}
}
ADMIN_FILTER.initFilter();
$('a.edit-export').click(function(){
	var $ob = $(this);
	$.ajax({
		type: "POST",
		url: $ob.attr('data-url'),
		data: {
			action_name: 'get',
			export_id: $ob.attr('data-id')
		},
		cache: false,
		success: function(data){
			$.fancybox.close();
			$.fancybox.open(data,{
				padding : 10,
				title: $ob.attr('data-title'),
				helpers: {
					overlay:{
						closeClick : false
					} 
				}
			});
			$('a.export-remove').unbind('click').click(function(){
				var $ob2 = $(this);
				$.ajax({
					type: "POST",
					url: $ob.attr('data-url'),
					data: {
						action_name: 'remove',
						export_id: $ob.attr('data-id'),
						candidate_id: $ob2.attr('data-id')
					},
					cache: false,
					success: function(data){
						if(data=='1'){
							$ob2.parent().remove();
						}else{
							alert(data);
						}
					}
				});
			});
		}
	});
	return false;
});
$('a.export-advance').click(function(){
	var $ob = $(this);
	$('input.export-chk').prop('checked',false);
	$.fancybox.close();
	$.fancybox.open($('#export-select'),{
		padding : 10,
		title: $ob.attr('data-title'),
		helpers: {
			overlay:{
				closeClick : false
			} 
		}
	});
	$('input#export-ok').unbind('click').click(function(){
		var $val = '';
		$('input.export-chk:checked').each(function(){
			$val+=$(this).val()+',';
		});
		if($val==''){
			alert('<?php echo __('export-error', null, 'export_exports')?>');
		}else{
			$.ajax({
				type: "POST",
				url: $ob.attr('data-url'),
				data: {
					action_name: 'export-advance',
					arr_value: $val,
					id: $ob.attr('data-id')
				},
				cache: false,
				success: function(data){
					$.fancybox.close();
					$.fancybox.open(data,{
						padding : 10,
						title: $ob.attr('data-title'),
						helpers: {
							overlay:{
								closeClick : false
							} 
						}
					});
				}
			});
		}
	});
});

<?php end_slot()?>

<?php slot('header_css')?>
<style type="text/css">
<!-- 

div.box-content-main table.table-list td.description{
	width: 200px;
}
div.box-content-main table.table-list td.tags{
	width: 200px;
}
.export-btn{
	cursor: pointer;
	border: 1px solid #ccc;
	padding: 5px 10px;	
	text-align: center;
	
}
#page-content-right #inner .box-content .box-content-main table.table-list .action{
	width: 200px;
}
-->
</style>
<?php end_slot()?>
<div style="display: none">
	<div id="export-select">
		<div style="border: 1px solid #ccc; padding: 10px; margin-bottom: 10px;">
		<?php 
		$itpp = 9;
		$ctt = count($data['export_select']);
		$step = ceil($ctt/$itpp);
		for($i = 0; $i < $step; $i++):
			?>
			<div style="float: left; width: 200px;">
			<?php 
			for ($in = $i * $itpp; $in<$ctt && $in < $i * $itpp + $itpp; $in ++):

		echo '<input class="export-chk" type="checkbox" name="exports[]" value="'.$data['export_select'][$in].'"/>', __('export-'.$data['export_select'][$in], null, 'export_exports'), '<br/>' ;
		endfor;?>
		</div>
		<?php endfor;?>
		<div style="clear: both"></div>
		</div>
		<div style="text-align: right">
			<input type="button" class="export-btn" id="export-ok" value="<?php echo __('export-ok', null, 'export_exports')?>"/>
		</div>
	</div>
</div>
<div class="box-navigation">
	<?php echo $data['navigation']?>
</div>
<div class="clr"></div>
<div class="box-filter">
	<form action="?" method="get" name="filter_form" id="filter_form">
		<input type="text" maxlength="255" name="filter[filter_key]" id="filter_key" value="<?php echo empty($data['filter']['filter_key'])?__('filter_key_search',null,'table_list'):$data['filter']['filter_key']?>"/>
		<input type="submit" name="filter[filter_submit]" id="filter_submit" class="button" value="<?php echo __('filter_submit',null,'table_list')?>"/>
	</form>
</div>
<div class="clr"></div>
<div class="box-content">
	<form action="<?php echo $data['filter_action']?>" method="post" name="form_main" id="form_main">
		<input type="hidden" value="-1" name="action_token" id="action_token"/>
		<input type="hidden" value="none" name="action_name" id="action_name"/>
		<div class="control">
			<a href="#" class="a-control delete" data-action="<?php echo ADMIN_DEFINED::DELETE_RECORD?>" data-require="selected" data-confirm="confirm"><?php echo __('control_delete',null,'table_list')?></a>
		</div>
		<div class="clr"></div>
		<div class="box-content-main">
			<table class="table-list" cellspacing="0" cellpadding="0" border="0">
				<tr>
					<td class="head checkbox-select"><input type="checkbox" name="select_checkall" id="select_checkall" title="<?php echo __('to_checkall',null,'table_list')?>" class="chk-select"/></td>
					<td class="head name"><?php echo __('head_name',null,'export_exports')?></td>
					<td class="head action"><?php echo __('action',null,'table_list')?></td>
				</tr>
				
			<?php 
				$count_for = 0;
				foreach($data['list'] as $val):?>
				<tr class="class<?php echo ++$count_for%2?> enable-<?php echo intval($val['is_enabled'])?>">
					<td class="checkbox-select"><input type="checkbox" name="select_list[]" class="select_list" value="<?php echo $val['id']?>" id="select_<?php echo $val['id']?>" title="<?php echo __('to_check',null,'table_list')?>" /></td>
					<td class="name">
						<a href="#" class="edit-export"  data-id="<?php echo $val['id']?>" data-title="<?php echo __('export-edit-title', null, 'export_exports')?>" data-url="<?php echo sfConfig::get('app_prefix').url_for2('export_candidate') ?>"><?php echo $val['name']?></a>
					</td>
					
					<td class="action">
						<a target="_blank" href="<?php echo sfConfig::get('app_prefix').url_for2('candidate_add_export', array('id' => $val['id'], 'action_name' => 'export')) ?>" ><?php echo __('export', null, 'export_exports')?></a>
						| <a href="#" data-id="<?php echo $val['id']?>" data-title="<?php echo __('export-advance-title', null, 'export_exports')?>" class="export-advance" data-url="<?php echo sfConfig::get('app_prefix').url_for2('candidate_add_export') ?>" ><?php echo __('export-advance', null, 'export_exports')?></a>
					</td>
				</tr>
				<?php endforeach; ?>
				<?php if($count_for ==0):?>
				<tr>
					<td colspan="3">
						<div  class="note"><?php echo __('no_row_founded',null,'table_list')?></div>
					</td>
				</tr>
				<?php endif;?>
			</table>
		</div>
		<div class="clr"></div>
		<div class="control">
			<a href="#" class="a-control delete" data-action="<?php echo ADMIN_DEFINED::DELETE_RECORD?>" data-require="selected"><?php echo __('control_delete',null,'table_list')?></a>
		</div>
		<?php if(count($data['pagination_pager'])>1):?>
		<div class="pagination">
			<span><?php echo __('pagination_text',null,'table_list')?></span>
			<span class="pagination"> 
			<?php foreach ($data['pagination_pager'] as $p):?>
				<a href="<?php echo empty($p['url'])?'#':($data['app_prefix'].$p['url'])?>" class="<?php echo $p['page_class']?>"><?php echo $p['page_num']?></a>
			<?php endforeach;?>
			</span>
			<div class="clr"></div>
		</div>
		<?php endif;?>
		<div class="clr"></div>
	</form>
</div>